// pages/mycollect/mycollect.js
let network = require("../../utils/network.js");
let app = getApp();
let url = app.globalData.url;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    that.collectlist()
  },
  collectlist(){
    var that = this
    network.request({
      url: url+'/AppletsApi/Collection/collectionList.html',
      data: {
        applet_openid: wx.getStorageSync('applet_openid'),
      },
      method: 'post',
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (data) {
        that.setData({
          list: data.data.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  del:function(e){
    var that = this
    let id = e.currentTarget.dataset.index
    network.request({
      url: url+'/AppletsApi/Collection/collectionDel.html',
      data: {
        applet_openid: wx.getStorageSync('applet_openid'),
        collection_id: id
      },
      method: 'post',
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (data) {
        console.log(data)
      }
    })
    that.collectlist()
  },
  bindCart:function(){
    wx.switchTab({
      url: '/pages/classify/classify',
    })
  },
})